package com.tubeonfire.ajax.admin;

import java.io.IOException;
import java.util.Calendar;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tubeonfire.entity.Channel;
import com.tubeonfire.model.admin.ChannelModel;

@SuppressWarnings("serial")
public class ProcessChannel extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		String action = request.getParameter("action");
		if (action != null && action.equals("delete")) {
			String id = request.getParameter("id");
			Channel obj = ChannelModel.getById(id);
			if (obj != null) {
				ChannelModel.delete(obj);
			}
		} else if (action != null && action.equals("bump")) {
			String id = request.getParameter("id");
			Channel obj = ChannelModel.getById(id);
			if (obj != null) {
				obj.setBumpPoint(Calendar.getInstance().getTimeInMillis());
				ChannelModel.insert(obj);				
			}
		}
	}
}
